﻿<%@ Page Language="C#" MasterPageFile="~/Forum.master" AutoEventWireup="true" CodeBehind="ThreadPage.aspx.cs" Inherits="Forums.ThreadPage" %>
<%@ Register src="UserControls/SearchFunction.ascx" tagname="SearchFunction" tagprefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="searchContentHolder" runat="server">
    <uc1:SearchFunction ID="SearchFunction1" runat="server" />
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="mainContentHolder" runat="server">
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
        DataKeyNames="topic_id"  DataSourceID="ForumThreadPage" AllowPaging="True">
        <Columns>
            <asp:TemplateField HeaderText="Thread" SortExpression="thread_subject" >
                <ItemTemplate>
                    <asp:Label ID="Label3" runat="server" Text='<%# Eval("thread_subject") %>'></asp:Label>
                    <br />
                    <asp:Label ID="Label2" runat="server" Text='<%# Eval("thread_body") %>'></asp:Label>
                    <br />
                    <asp:Label ID="Label4" runat="server" Text='<%# Eval("reply") %>'></asp:Label>                    
                </ItemTemplate>
                <HeaderStyle CssClass="threadHeader" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Posted By">
                <ItemTemplate>
                    <%#Eval("member_name")%>
                    <br />
                    <img src="UserAvatar.aspx?user_id=<%#Eval("user_accnt") %>" alt="N/A" />
                </ItemTemplate>
            </asp:TemplateField>

            <asp:BoundField DataField="date_posted" HeaderText="Date Posted" 
                SortExpression="date_posted" DataFormatString="{0:D}" >
                <HeaderStyle CssClass="threadHeader" />
            </asp:BoundField>
            <asp:HyperLinkField DataNavigateUrlFields="topic_Id" 
                DataNavigateUrlFormatString="ReportPage.aspx?topicId={0}" Text="Report This">
                <ControlStyle CssClass="hyperlink" />
               </asp:HyperLinkField>
        </Columns>
    </asp:GridView>
        <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
        <asp:Label ID="lblReplyValidator" runat="server" 
            Text="You Must Enter a Comment" Visible="False" SkinID="error"></asp:Label>
    <br />
        <asp:TextBox ID="txtSubmitReply" runat="server" Width="350px" MaxLength="900" 
            Height="147px"></asp:TextBox>
        <asp:Button ID="btnSubmitReply" runat="server" onclick="btnSubmit_Click" 
            Text="Submit Reply" CssClass="submitButton" />
        <asp:Button ID="btnClear" runat="server" Text="Clear" 
            onclick="btnClear_Click" CssClass="submitButton" />
    <asp:SqlDataSource ID="ForumThreadPage" runat="server" 
        ConnectionString="<%$ ConnectionStrings:CentForumsDB %>" SelectCommand="SELECT

	topic.topic_id,
	topic.refers_to,
	topic.thread_subject,
	topic.thread_body,
	topic.reply,
	registration.member_name,
	topic.date_posted,
	registration.user_accnt
	--do we want anything else??
	
FROM
	topic INNER JOIN registration ON topic.user_accnt = registration.user_accnt
WHERE	topic.topic_id = @topicId OR
		topic.refers_to = @topicId AND
                topic.deleted != 1
ORDER BY topic.date_posted
">
        <SelectParameters>
            <asp:QueryStringParameter Name="topicId" QueryStringField="topicId" />
        </SelectParameters>
    </asp:SqlDataSource>
</asp:Content>
